| 1 |  |  | import Vue from 'vue'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 | 4 |  | export const setConfig = function(state, config) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | 	Vue.set(state, 'config', Object.assign({}, state.config, config)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 | 4 |  | export const setLastCommentTime = function(state) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | 	state.lastCommentTime = new Date(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | }; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 11 | 4 |  | export const setMaxDepth = function(state, depth) { | 
            
                                                                        
                            
            
                                    
            
            
                | 12 | 4 |  | 	if (typeof depth !== 'number') { | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  | 		throw 'Depth must be an integer'; | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  | 	state.maxDepth = depth; | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 | 4 |  | export const setOrderBy = function(state, orderBy) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	state.orderBy = orderBy; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 | 4 |  | export const orderByNewest = function(state) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	state.orderBy = 'newest'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 4 |  | export const oderByOldest = function(state) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	state.orderBy = 'oldest'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 | 4 |  | export const setUser = function(state, user) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	Vue.set(state, 'user', user); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 4 |  | export const addComment = function(state, comment) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	let comments = state.comments; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	comment.created = new Date(comment.created); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	comments.push(comment); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	Vue.set(state, 'comments', comments); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 4 |  | export const deleteComment = function(state, comment) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	let comments = state.comments.filter(function(commentFromList) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 		return commentFromList.id !== comment.id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	Vue.set(state, 'comments', comments); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 4 |  | export const updateComment = function(state, editedComment) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	state.comments.forEach(function(comment) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 4 |  | 		if (comment.id == editedComment.id) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 			let index = state.comments.indexOf(comment); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 			state.comments[index] = editedComment; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 4 |  | export const updatePagination = function(state, data) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 2 |  | 	let key = data.model + data.modelId + data.parentId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 2 |  | 	let pagination = Object.assign({}, state.pagination); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 2 |  | 	pagination[key] = data.pagination; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 2 |  | 	Vue.set(state, 'pagination', pagination); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 | 4 |  | export const clearComments = function(state) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	Vue.set(state, 'comments', []); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 70 |  |  | }; | 
            
                                                        
            
                                    
            
            
                | 71 |  |  |  |